// ==UserScript==
// @name         弹出产品详情
// @namespace 	 test
// @version      1.0.0
// @description  添加购买链接
// @author       Zoro.Zhu
// @include      https://www.dianxiaomi.com/product/index.htm
// @exclude      *://*.eggvod.cn/*
// @connect      *
// @require      https://code.jquery.com/jquery-2.1.4.min.js
// @grant        window.close
// ==/UserScript==
function task() {
    var i = 1;
    var int=self.setInterval(function () {
        var result = document.evaluate("//*[@id='sysProMsg']/tr[" + i + "]/td[10]/a[1]/@href", document, null, XPathResult.ANY_TYPE, null);
        var nodes = result.iterateNext(); //枚举第一个元素
        var url = 'https://www.dianxiaomi.com/';
        var productUrl = '';
        if(nodes.value == null){
            alert("//*[@id='sysProMsg']/tr[" + i + "]/td[10]/a[1]/@href");
            return false;
        }
        productUrl = url + nodes.value;
        window.open(productUrl,"_blank");
        i = i + 2;
        if(i > 199){
            window.clearInterval(int);
            $('a[title=下一页]').click();
            task();
        }
    },3000);
}

(function() {
    document.getElementById('syncFromWishModal').style.display="none";
    $('.advancedSearchBtn').click();
    $('#inventoryRight').val(99);
    $('.btn.btn-primary.mLeft10').click();
    $('.advancedSearchBtn').click();
    $('.myj-aFocus').get(30).click();
    task();
})();
